package com.maybach.workflow.common.api;


import com.maybach.workflow.common.api.exception.FlowException;
import com.maybach.workflow.common.api.node.TaskNode;
import com.maybach.workflow.common.ext.FlowActInfo;
import com.maybach.workflow.common.ext.FlowTaskInfo;
import com.maybach.workflow.common.ext.IFlowActInfo;
import com.maybach.workflow.common.ext.ITaskActInfo;
import com.maybach.workflow.common.model.FlowDO;

import java.util.List;

/**
 * Created by houenxun on 15/10/19.
 *
 * 流程引擎放完接口
 */
public interface IFlowEngine {
    /**
     * 启动流程
     * @param bizId
     * @param bizType
     * @return flowId
     */
    Long startFlow(Long bizId, String bizType);

    /**
     * 启动流程
     * @param flowActInfo
     * @return
     */
    Long startFlow(FlowActInfo flowActInfo);

    /**
     * 执行任务
     * @param taskId
     */
    void executeTask(Long taskId);

    /**
     * 执行任务
     * @param taskActInfo
     */
    void executeTask(ITaskActInfo taskActInfo);

    /**
     * 操作流程 进行关闭 撤销申请 暂停等操作
     * @param flowActInfo
     */
    void operaterFlow(IFlowActInfo flowActInfo);

    /**
     * 获取任务信息
     */
    List<FlowTaskInfo> getTasks(Long flowId, boolean filterByRole);


    List<FlowTaskInfo> getTasks(FlowDO flowDO, boolean filterByRole);

    List<FlowTaskInfo> getTasks(String flowBizType, Long bizId, boolean filterByRole);

    /**
     * 获取后续的结点
     * @param flowId
     *
     * @return
     */
    List<TaskNode> getNextTasks(Long flowId);

    /**
     * 检查当前任务是否允许操作，如果不允许抛出异常
     * @param taskId
     * @throws FlowException
     */
    void checkTaskAllow(Long taskId) throws FlowException;

    /**
     * 当前任务是否允许操作，如果不允许 返回false
     * @param taskId
     * @return
     */
    boolean isTaskAllow(Long taskId);

}
